package combat;

import impsoft.bots.reflection.NPC;

import java.util.Arrays;

public class Monster {
	private String name;
	private int id;
	private int[] ignoreLevels;

	public Monster(String name, int id) {
		this(name, id, new int[] {});
	}

	public Monster(String name, int id, int[] ignoreLevels) {
		this.name = name;
		this.id = id;
		this.ignoreLevels = ignoreLevels;
	}

	public boolean matches(NPC npc) {
		return idMatches(npc.getType()) && levelMatches(npc.getLevel()) && nameMatches(npc.getName());
	}

	public boolean nameMatches(String name) {
		return this.name.equalsIgnoreCase(name);
	}

	public boolean idMatches(int id) {
		return this.id == id;
	}

	public boolean levelMatches(int npcLevel) {
		for (int level : ignoreLevels) {
			if (npcLevel == level) {
				return false;
			}
		}

		return true;
	}

	public String getName() {
		return name;
	}

	public int getId() {
		return id;
	}

	public int[] getIngoredLevels() {
		return ignoreLevels;
	}

	@Override
	public String toString() {
		return id + ":" + name + ":(" + Arrays.toString(ignoreLevels) + ")";
	}
}
